package com.fdb.efp.nls.service.impl.sx;

import com.fdb.efp.nls.service.domain.sx.NlsCreditInfoExd;
import com.fdb.efp.nls.service.facade.sx.NlsCreditInfoExdService;
import com.fdb.efp.nls.service.vo.sx.NlsCreditInfoExdVO;
import com.fdb.basic.framework.core.base.FrameworkService;
import com.fdb.efp.nls.service.dao.sx.NlsCreditInfoExdDao;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Objects;

/**
 * 需求编号：ECIF<br/>
 * 问题编号：<br/>
 * 功能描述：<br/>
 * 开发人员：dengqiwen<br/>
 * 创建时间：2020/9/15 11:15
 */
@Service("nlsCreditInfoExdService")
public class NlsCreditInfoExdServiceImpl implements NlsCreditInfoExdService, FrameworkService {

    private static Logger logger = LoggerFactory.getLogger(NlsCreditInfoExdServiceImpl.class);

    @Autowired
    private NlsCreditInfoExdDao nlsCreditInfoExdDao;

    @Override
    public int insert(NlsCreditInfoExdVO pojo) {
        logger.debug("当前新增数据为:"+ pojo.toString());
        int num = 0;
        try {
            NlsCreditInfoExd nlsCreditInfoExd=new NlsCreditInfoExd();
            beanCopy(pojo,nlsCreditInfoExd);
             num = nlsCreditInfoExdDao.insert(nlsCreditInfoExd);
        } catch (Exception e) {
            logger.error("新增数据发生异常!", e);
            num = -1;
        }
        logger.debug("当前新增数据条数为:"+ num);
        return num;
    }



    @Override
    public NlsCreditInfoExdVO queryByPk(NlsCreditInfoExdVO pojo) {
        logger.debug("当前查询参数信息为:"+ pojo);
        try {
            NlsCreditInfoExd nlsCreditInfoExd=new NlsCreditInfoExd();
            beanCopy(pojo,nlsCreditInfoExd);
            NlsCreditInfoExd nlsCreditInfoExds = nlsCreditInfoExdDao.queryByPk(nlsCreditInfoExd);
            if (Objects.nonNull(nlsCreditInfoExds)) {
                return beanCopy(nlsCreditInfoExds,new NlsCreditInfoExdVO());
            } else {
            logger.debug("当前查询结果为空!");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }


}
